home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / Testing & Debugging / Heap Purge dcmd / hp.a next >
Encoding:
Text File  |  1992-07-15  |  3.4 KB  |  107 lines  |  [TEXT/MPS ]

  1.             include        'SysErr.a'
  2.             include        'SysEqu.a'
  3.             include        'Traps.a'
  4.  
  5. allRegs        REG            D0-D7/A0-A5
  6.  
  7.             proc
  8.             
  9.             import        PurgeAllBlocks
  10.             
  11. ; ————————————————————————————————————————————————————————————————————————————
  12. ;
  13.  
  14.             export    SaveMyA5, GetMyA5
  15.             
  16. pMyA5        dc.l    0
  17.  
  18. SaveMyA5
  19.             lea        pMyA5,A0
  20.             move.l    A5,(A0)
  21.             rts
  22.             
  23. GetMyA5
  24.             move.l    pMyA5,4(SP)
  25.             rts
  26.  
  27.  
  28. ; ————————————————————————————————————————————————————————————————————————————
  29. ;
  30. ; Storage for the old patch addresses, used to call through once the patch 
  31. ; code executes. These are essentially globals, used by the asm code. They are 
  32. ; specifically not exported, so that the Pascal code cannot access them 
  33. ; directly. There are a number of interface routines I set up so that Pascal 
  34. ; can get and set them, but has to go through this file. You know, sort of 
  35. ; object like.
  36. ;
  37. pFirstSavedTrap           equ         *
  38. pOldNewPtr                dc.l        0
  39. pOldNewHandle             dc.l        0
  40. pOldReallocHandle         dc.l        0
  41. pOldSetPtrSize            dc.l        0
  42. pOldSetHandleSize         dc.l        0
  43. pOldMoveHHi               dc.l        0
  44.  
  45. ; ————————————————————————————————————————————————————————————————————————————
  46. ; When I'm am setting up the world, I call NGetTrapAddress to get the old 
  47. ; version of the traps. I need to save that dude off so I can get back there 
  48. ; when needed. This routine is a handy interface to the high-level world, 
  49. ; isolating this asm junk from the code. All these routines are the same, just 
  50. ; a different variable being affected. This hunk uses the PC-Relative 
  51. ; addressing mode in order to get the address of the variable being set. This 
  52. ; allows the code to function without any explicit global space, since the 
  53. ; code acts like globals here.
  54. ;
  55. ; The interface is:
  56. ;
  57. ;    PROCEDURE  SaveOldTrapAddress (address: LongInt; addressKind: Integer);
  58. ;
  59.  
  60.             export        SaveOldTrapAddress
  61.  
  62. SaveOldTrapAddress
  63.             MOVE.L        (SP)+,A0               ; get the return address
  64.             move.w        (SP)+,D0
  65.             asl.w         #2,D0
  66.             LEA           pFirstSavedTrap,A1     ; the variable to be setting
  67.  
  68.             MOVE.L        (SP)+,(A1,D0.w)   ; save it, pulling parameter too
  69.             JMP           (A0)              ; it's saved, return to high-level
  70.  
  71.             export        NewNewPtr, NewNewHandle, NewReallocHandle
  72.             export        NewSetPtrSize, NewSetHandleSize, NewMoveHHi
  73.  
  74. NewNewPtr
  75.             move.l        pOldNewPtr,-(SP)
  76.             bra.s         Common
  77.  
  78. NewNewHandle
  79.             move.l        pOldNewHandle,-(SP)
  80.             bra.s         Common
  81.  
  82. NewReallocHandle
  83.             move.l        pOldReallocHandle,-(SP)
  84.             bra.s         Common
  85.  
  86. NewSetPtrSize
  87.             move.l        pOldSetPtrSize,-(SP)
  88.             bra.s         Common
  89.  
  90. NewSetHandleSize
  91.             move.l        pOldSetHandleSize,-(SP)
  92.             bra.s         Common
  93.  
  94. NewMoveHHi
  95.             move.l        pOldMoveHHi,-(SP)
  96. ;            bra.s        Common
  97.  
  98. Common
  99.             movem.l       allRegs,-(SP)
  100.             move.w        D1,-(SP)
  101.             bsr           PurgeAllBlocks
  102.             movem.l       (SP)+,allRegs
  103.             rts
  104.  
  105.             ENDP
  106.             END
  107.